package com.fsxgt.datagrid.component.controller;

import java.io.IOException;
import java.util.concurrent.ExecutionException;

import org.apache.ibatis.executor.ExecutorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.fsxgt.datagrid.component.bo.CmpExecSqlBO;
import com.fsxgt.datagrid.component.service.impl.CmpExecSqlService;
import com.fsxgt.datagrid.core.exception.DataGridException;
import com.fsxgt.datagrid.core.utils.ReturnT;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Api(tags = "sql执行组件", value = "ExecSqlController")
@RequestMapping(produces = "application/json; charset=UTF-8",path = "/execSql")
@RestController
public class ExecSqlController extends BaseController {


	@Autowired
	private CmpExecSqlService cmpExecSqlService;
	

 
	
	@ApiOperation(hidden = true, value = "保存", notes = "")
	@RequestMapping(path = "/saveExecSql", method = RequestMethod.POST)
	public ReturnT saveCmpExecSql(@RequestBody CmpExecSqlBO bo) throws DataGridException, IOException, ExecutorException, NumberFormatException, ExecutionException {
		
		cmpExecSqlService.saveCmpExecSql(bo);
		
		return new ReturnT();

	}
	
	@ApiOperation(hidden = true, value = "获取组件", notes = "")
	@RequestMapping(path = "/getExecSql", method = RequestMethod.POST)
	public ReturnT getSyncOffline(@RequestBody CmpExecSqlBO cmpExecSqlBO) throws DataGridException, IOException, ExecutorException, NumberFormatException, ExecutionException {
		
		CmpExecSqlBO bo = cmpExecSqlService.getCmpExecSql(cmpExecSqlBO);
		
		return new ReturnT(bo);

	}
	
	

	
	
	
	


	

}